package com.kun.admin.authority.service;

import com.kun.base.redis.RedisClient;
import org.springframework.stereotype.Service;

import java.util.Iterator;
import java.util.Set;

/**
 * Created by likun on 2017/8/12.
 */
@Service
public class CacheServiceImpl implements CacheService {

    @Override
    public void clearPermission() {
        String permissionsName="user:user*";
        RedisClient redisClient=new RedisClient();
        //获取所有用户的权限缓存key
        Set<String> permissionSet = redisClient.keysByStr(permissionsName);
        Iterator<String> permissionIterator = permissionSet.iterator();
        while (permissionIterator.hasNext()){
            redisClient.delete(permissionIterator.next());//删除缓存
        }
    }
}
